/*
 * Ext JS Library 3.0.0
 * Copyright(c) 2006-2009 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license
 */

//Funcion para verificar que los password coincidan
Ext.apply(Ext.form.VTypes, {
    password : function(val, field) {
        if (field.initialPassField) {
            var pwd = Ext.getCmp(field.initialPassField);
            return (val == pwd.getValue());
        }
        return true;
    },

    passwordText : 'Passwords do not match'
});


/*
Ext.onReady(function(){

    Ext.QuickTips.init();
*/
    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';

    var bd = Ext.getBody();

    /*
    Variables creadas por jeante  
    */
    var cursos = new Ext.data.SimpleStore({
    fields: ['id', 'cursos'],
    data : [['1','7501-1'],['2','DESa'],['3','756-1']]
});






    /*
     * ================  Form 2  =======================
     */
  /* bd.createChild({tag: 'h2', html: 'Form 2 - Adding fieldsets'});*/

    var registro = new Ext.FormPanel({
        labelWidth: 75, // label settings here cascade unless overridden
        url:'save-form.php',
        frame:true,
        title: 'Registro de Usuario',
        bodyStyle:'padding:5px 5px 0',
        width: 350,
	//region:'south',
        items: [
	      {
		xtype:'fieldset',
		title: 'Usuario',
		collapsible: true,
		autoHeight:true,
		defaults: {width: 210},
		defaultType: 'textfield',
		items :[{
		fieldLabel: 'Login',
		name: 'login'
		},
		{
		    inputType: 'password',
		    fieldLabel: 'Contrase&ntilde;a',
		    name: 'pass',
		    id: 'pass'
		},
		{
		  inputType: 'password',
		  fieldLabel: 'Confirmacion Contrase&ntilde;a',
		  name: 'pass-cfrm',
		  vtype: 'password',
		  initialPassssField: 'pass' // id of the initial password field
		}
            ]
        },
          {
            xtype:'fieldset',
           checkboxToggle:true,
            title: 'Informacion Estudiante',
            autoHeight:true,
	         defaultType: 'textfield',
            defaults: {width: 210},
            collapsed: true,
            items :[{
                    fieldLabel: 'Codigo',
                    name: 'codigo',
                    allowBlank:false
                },{
                    fieldLabel: 'Nombre',
                    name: 'nombre'
                },{
                    fieldLabel: 'Apellido',
                    name: 'apellido'
                }, {
                    fieldLabel: 'Grupo de Trabajo',
                    name: 'grupoTrabajo',
                },
                 {
                    xtype: 'combo',
                    name: 'cursos_combo',
                    fieldLabel: 'Cursos',
                    mode: 'local',
                    store: cursos,
                    displayField:'cursos',
                    width: 120
	              },
                
            ]
        },
  
{
            xtype:'fieldset',
            checkboxToggle:true,
            title: 'Informacion Profesor',
            autoHeight:true,
	          defaultType: 'textfield',
            defaults: {width: 210},
            collapsed: true,
            items :[{
                    fieldLabel: 'Cedula',
                    name: 'cedula',
                    allowBlank:false
                },{
                    fieldLabel: 'Nombre',
                    name: 'nombre'
                },{
                    fieldLabel: 'Apellido',
                    name: 'apellido'
                }, {
                    xtype: 'combo',
                    name: 'cursos_combo',
                    fieldLabel: 'Cursos',
                    mode: 'local',
                    store: cursos,
                    displayField:'cursos',
                    width: 120
	              }
            ]
        }

],

        buttons: [{
            text: 'Guardar',
	    handler : function()
	    {
	      registro.getForm().submit();
	    }
        },{
            text: 'Cancelar'
        }]
    });
/*
    registro.render(document.body);

});
/*
//Ext.onReady(Language.init,Language);
*/